import { Scene, PolygonLayer, LineLayer, PointLayer, ILayer } from "@antv/l7";
import { Map } from "@antv/l7-maps";
import data from "@/assets/cangzhou";
const sub = [{
    name: '青县人民政府',
    longitude: 116.804137,
    latitude: 38.583657
}, {
    name: '流河镇',
    longitude: 116.854868, latitude: 38.690879
}, {
    name: '金牛镇',
    longitude: 117.033845, latitude: 38.586345
}, {
    name: '上伍乡',
    longitude: 116.918291, latitude: 38.517256
}, {
    name: '陈嘴乡',
    longitude: 116.882841, latitude: 38.464772
}, {
    name: '盘古镇',
    longitude: 116.798344, latitude: 38.5283
}, {
    name: '新兴镇',
    longitude: 116.780593, latitude: 38.437201
}, {
    name: '木门店镇',
    longitude: 116.743663, latitude: 38.471597
}]
export class Box11 {
    scene: Scene;
    joinedLayer?: ILayer;
    constructor() {
        this.scene = new Scene({
            id: "box11",
            map: new Map({
                center: [116.820014, 38.559072],
                zoom: 9.8,
                style: "normal"
            }),
            logoVisible: false,
        });
        this.scene.setMapStatus({
            dragEnable: false,
            doubleClickZoom: false,
            zoomEnable: false
        });
        this.scene.on("loaded", () => {
            const joinedLayer = new PointLayer({
                zIndex: 6,
            })
                .source(sub, {
                    parser: {
                        type: "json",
                        x: "longitude",
                        y: "latitude",
                    },
                })
                .shape("name", "text")
                .size(14)
                .color("#3575ca");
            const filllayer = new PolygonLayer({
                name: "fill",
            })
                .source(data)
                .shape("fill")
                .color("#59689b");
            const linelayer = new LineLayer({
                zIndex: 1,
                name: "line",
            })
                .source(data)
                .shape("line")
                .size(0.5)
                .color("#fff")
                .style({
                    opacity: 0.5,
                });
            this.scene.addLayer(joinedLayer);
            this.scene.addLayer(filllayer);
            this.scene.addLayer(linelayer);
        });
    }
    setDate(joined: any) {
        if (this.joinedLayer) {
            this.scene.removeLayer(this.joinedLayer)
        }
        this.joinedLayer = new PointLayer({
            zIndex: 6,
        })
            .source(joined, {
                parser: {
                    type: "json",
                    x: "longitude",
                    y: "latitude",
                },
            })
            .shape("simple")
            .size(4)
            .color("#37a5ee");
        this.joinedLayer
        this.scene.addLayer(this.joinedLayer);
    }
}
